package autosimmune.agents.cells.styles;

import java.awt.Color;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;

import repast.simphony.visualization.visualization2D.style.Style2D;
import edu.umd.cs.piccolo.PNode;
import edu.umd.cs.piccolo.nodes.PPath;
import edu.umd.cs.piccolo.nodes.PText;
import autosimmune.agents.cells.PC;

public class PCStyle2D implements Style2D<PC>{

	private Rectangle2D rect;
	
	public PCStyle2D(){
		rect = new Rectangle2D.Float(0, 0, 10, 10);
	}
	
	@Override
	public Rectangle2D getBounds(PC object) {
		return rect;
	}

	@Override
	public PText getLabel(PC object) {
		return null;
	}

	@Override
	public PNode getPNode(PC obj, PNode node) {
		Shape s = new Ellipse2D.Float(0, 0, 10, 10);
		PPath path = new PPath(s);
		path.setBounds(rect);
		path.setPaint(this.getPaint(obj));
		path.setStroke(this.getStroke(obj));
		path.setStrokePaint(this.getStrokePaint(obj));
		return path;
	}

	@Override
	public Paint getPaint(PC object) {

		if(object.isRegenerated()){
			return new Color(255, 200, 200, 255);
		}
		
		switch(object.getState()){
			case STRESSED:
				return Color.ORANGE;
			
			case NORMAL: 
				return Color.WHITE;
			
			case NECROSIS:
				return Color.BLACK;
				
			case APOPTOSIS:
				return new Color(0, 255, 0, 255);
			
			default:
				return Color.WHITE;
		}
	}

	@Override
	public double getRotation(PC object) {
		return 0;
	}

	@Override
	public Stroke getStroke(PC object) {
		return null;
	}

	@Override
	public Paint getStrokePaint(PC object) {
		return Color.BLACK;
	}

	@Override
	public boolean isScaled(PC object) {
		return true;
	}

}
